// 光学组件、函数、枚举、错误代码
#include <iostream>
#include <iomanip>
using namespace std;

enum Part {
    Part_lens,
    Part_mirror,
    Part_prism,
    Part_error,
};

int WhichPart(Part* part);

void DoOptics(Part part);

int main() {
    cout << "光学器件\n";

    Part part;
    if (WhichPart(&part) == 0) {
        DoOptics(part);
    }
    else {
        cout << "输入错误\n";
    }
    cout << "完毕\n";
}

int WhichPart(Part* part) {
    char Partname[4][10] = {
        "lens",
        "mirror",
        "prism",
        "error"
    };

    cout.setf(ios::left);
    for (int i = 0; i < 3; i++) {
        cout << setw(2) << (i+1) << setw(10) << Partname[i] << endl;
    }

    cout << "请输入光学器件编号: ";
    int choice;
    cin >> choice;

    if (choice >= 1 && choice <= 3) {
        *part = (Part)(choice-1);
        return 0;
    }
    else {
        *part = Part_error;
        return -1;
    }
}

void DoOptics(Part part) {
    switch (part) {
        case Part_lens:
            cout << "正在处理 lens\n";
            break;
        case Part_mirror:
            cout << "正在处理 mirror\n";
            break;
        case Part_prism:
            cout << "正在处理 prism stuff\n";
            break;
    }
}